﻿using System;
using System.Collections.Generic;
using System.Text;

namespace IScript
{
    /// <summary>
    /// 脚本调用外部函数委托
    /// </summary>
    /// <param name="function">函数名称</param>
    /// <param name="parameters">函数参数</param>
    public delegate object CallFunctionCallback(string function, params object[] parameters);

    /// <summary>
    /// 脚本从外部获取需要的参数的委托
    /// </summary>
    /// <param name="names">参数名</param>
    /// <returns>参数值</returns>
    public delegate string CallParameterCallback(string name);

    /// <summary>
    /// 脚本停止执行之后发生
    /// </summary>
    public delegate void StopCallback();

    /// <summary>
    /// 脚本接口
    /// </summary>
    public interface IScript
    {
        /// <summary>
        /// 设置脚本调用外部函数委托
        /// </summary>
        CallFunctionCallback ScriptCallFucntion { set; }

        /// <summary>
        /// 设置脚本从外部获取需要的参数的委托
        /// </summary>
        CallParameterCallback ScriptCallParameter { set; }

        /// <summary>
        /// 
        /// </summary>
        StopCallback StopCallback { set; }

        /// <summary>
        /// 脚本是否已经开始
        /// </summary>
        bool IsStarted { get; }

        /// <summary>
        /// 脚本开始，比如巡航或者识别只要一个开始就是脚本开始了
        /// </summary>
        /// <returns>true表示成功，false表示失败</returns>
        bool Start();

        /// <summary>
        /// 强制终止巡航识别线程    
        /// </summary>
        /// <returns>true表示成功，false表示失败</returns>
        bool Stop();       

        /// <summary>
        /// 为外部提供对脚本参数值进行设置的接口
        /// </summary>
        /// <param name="key">外部参数名称</param>
        /// <param name="value">外部参数值</param>
        /// <returns></returns>
        bool SetValue(string key, object value);

        /// <summary>
        /// 为外部提供获取脚本参数值的接口
        /// </summary>
        /// <param name="key">外部参数名称</param>
        /// <returns>外部参数值</returns>
        object GetValue(string key);
    }
}
